<?php

namespace Modules\Admin\Http\Controllers\Configurations;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Configurations;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Create
{
    /**
     *
     * @Route(path=/api/admin/configuration  method=post)
     */
    public function index()
    {
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid; 
        
        // 更新 $allowedKeys 和 $defaults
        $allowedKeys = [
            'name', 'content','is_enabled', 'admin_user_id', 'eid', 'sid'
        ];
        
        $defaults = [
            'admin_user_id' => $adminUserIdDefault,
            'eid' => $eidDefault,
            'sid' => $sidDefault,
        ];
        
        // 调用方法
        $instance = Configurations::safeCreateWithRequestParams($allowedKeys, $defaults);
        return Api::success();
    }

}